{include file="index/header"}
<body>
<div class="fly-panel fly-panel-user">
    <div class="tpt-admin">
        <div class="tpt-btn" style="float: left;margin: 0 20px 0 0">
            <a href="{:url('taoorder/add')}" class="layui-btn" style="float: left;margin-right: 5px;"><i class="layui-icon">&#xe608;</i> 订单入库</a>
        </div>
        <div style="float: left;">
            <form class="layui-form" action="" method="get">
                <input placeholder="输入关键字" name="ks" value="<?php echo input('ks');?>" type="text" class="layui-input" style="float: left;margin-right: 10px;width: 240px;">
                <button class="layui-btn" style="float: left;" value="查询" type="submit">查询</button>
            </form>
        </div>
        <form class="layui-form" enctype="multipart/form-data" method="post">
            <table width="100%" {empty name="GoodsList"}style="margin-bottom: -17px;"{/empty}>
            <tr>
                <th width="3%" align="center"><input type="checkbox" name="checkAll" lay-filter="checkAll"></th>
                <th width="5%" align="center">入库ID</th>
                <th width="5%" align="center">订单号</th>
                <th width="15%" align="center">商品标题</th>
                <th width="5%" align="center">付款金额</th>
                <th width="8%" align="center">实付款金额</th>
                <th width="5%" align="center">状态</th>
                <th width="5%" align="center">商品数量</th>
                <th width="5%" align="center">佣金金额</th>
                <th width="5%" align="center">佣金比率</th>
                <th width="5%" align="center">技术服务费比率</th>
                <th width="5%" align="center">订单创建时间</th>
                <th width="5%" align="center">订单结算时间</th>
                <th width="7%" align="center">基本操作</th>
            </tr>
            {empty name="TaoorderList"}
            <tr style="height: 0px;border: none;">
                <td style="height: 0px;border: none;"></td>
                <td style="height: 0px;border: none;"></td>
                <td style="height: 0px;border: none;"><img src="__ROOT__/public/img/no_data.jpg" width="50" height="0"></td>
            </tr>
            {else /}
            {volist name="TaoorderList" id="vo"}
            <tr>
                <td align="center"><input type="checkbox" name="ids[{$vo.id}]" lay-filter="checkOne" value="{$vo.id}"></td>
                <td align="center">{$vo.id}</td>
                <td align="center">{$vo.trade_id}</td>
                <td style="padding:0 20px;"><?php echo mb_substr(strip_tags(htmlspecialchars_decode($vo['item_title'])), 0,20, 'utf-8');?>...</td>
                <td align="center">{$vo.alipay_total_price}</td>
                <td align="center">{$vo.pay_price}</td>
                <td align="center">{$vo.tk_status}</td>
                <td align="center">{$vo.item_num}</td>
                <td align="center">{$vo.total_commission_fee}</td>
                <td align="center">{$vo.total_commission_rate}</td>
                <td align="center">{$vo.tkAlimmShareRate}</td>
                <td align="center">{$vo.establish_time}</td>
                <td align="center">{$vo.earning_time}</td>
                <td align="center">
                    <a class="layui-btn layui-btn-mini layui-btn-warm" href="{:url('taoorder/edit',array('id'=>$vo['id']))}">修改</a>
                    <a class="layui-btn layui-btn-mini layui-btn-danger del_btn" member-id="{$vo.id}" title="删除" nickname="{$vo.item_title}">删除</a>
                </td>
            </tr>
            {/volist}
            {/empty}
            </table>
            <div class="layui-form-item">
                <div style="margin-top: 20px;float: left;">
                    <button class="layui-btn" lay-submit lay-filter="delete">删除选中</button>
                </div>
                <div class="pages" style="float: right;">{$TaoorderList->render()}</div>
            </div>
        </form>
    </div>
</div>
{include file="index_footer"}
<script type="text/javascript">
    function changechoice(o){
        var change=$(o).attr("change");
        $.ajax({
            type:"post",
            dataType:"json",
            data:{change:change},
            url:"{:url('goods/changechoice')}",
            success:function(data){
                if(data == 1){
                    $(o).attr("class","layui-unselect layui-form-switch");
                }else{
                    $(o).attr("class","layui-unselect layui-form-switch layui-form-onswitch");
                }
            }
        });
    }
    function changesettop(o){
        var change=$(o).attr("change");
        $.ajax({
            type:"post",
            dataType:"json",
            data:{change:change},
            url:"{:url('goods/changesettop')}",
            success:function(data){
                if(data == 1){
                    $(o).attr("class","layui-unselect layui-form-switch");
                }else{
                    $(o).attr("class","layui-unselect layui-form-switch layui-form-onswitch");
                }
            }
        });
    }
    function changeshow(o){
        var change=$(o).attr("change");
        $.ajax({
            type:"post",
            dataType:"json",
            data:{change:change},
            url:"{:url('taoorder/changeshow')}",
            success:function(data){
                if(data == 1){
                    $(o).attr("class","layui-unselect layui-form-switch");
                }else{
                    $(o).attr("class","layui-unselect layui-form-switch layui-form-onswitch");
                }
            }
        });
    }
</script>
<script type="text/javascript">
    layui.use(['form', 'laydate'], function(){
        var form = layui.form()
            ,layer = layui.layer
            ,laydate = layui.laydate
            ,jq = layui.jquery;

        jq('.del_btn').click(function(){
            var name = jq(this).attr('nickname');
            var id = jq(this).attr('member-id');
            layer.confirm('确定删除【'+name+'】?', function(index){
                loading = layer.load(2, {
                    shade: [0.2,'#000']
                });
                jq.post('{:url("taoorder/dels")}',{'id':id},function(data){
                    if(data.code == 200){
                        layer.close(loading);
                        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                            location.reload();
                        });
                    }else{
                        layer.close(loading);
                        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
                    }
                });
            });
        });

        form.on('checkbox(checkAll)', function(data){
            if(data.elem.checked){
                jq("input[type='checkbox']").prop('checked',true);
            }else{
                jq("input[type='checkbox']").prop('checked',false);
            }
            form.render('checkbox');
        });

        form.on('checkbox(checkOne)', function(data){
            var is_check = true;
            if(data.elem.checked){
                jq("input[lay-filter='checkOne']").each(function(){
                    if(!jq(this).prop('checked')){ is_check = false; }
                });
                if(is_check){
                    jq("input[lay-filter='checkAll']").prop('checked',true);
                }
            }else{
                jq("input[lay-filter='checkAll']").prop('checked',false);
            }
            form.render('checkbox');
        });

        form.on('submit(delete)', function(data){
            var is_check = false;
            jq("input[lay-filter='checkOne']").each(function(){
                if(jq(this).prop('checked')){ is_check = true; }
            });
            if(!is_check){
                layer.msg('请选择数据', {icon: 2,anim: 6,time: 1000});
                return false;
            }
            layer.confirm('确定批量删除?', function(index){
                loading = layer.load(2, {
                    shade: [0.2,'#000']
                });
                var param = data.field;
                jq.post('{:url("taoorder/delss")}',param,function(data){
                    if(data.code == 200){
                        layer.close(loading);
                        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                            location.reload();
                        });
                    }else{
                        layer.close(loading);
                        layer.msg(data.msg, {icon: 2,anim: 6, time: 1000});
                    }
                });
            });
            return false;
        });

        form.on('submit(delete_all)', function(data){
            layer.confirm('确定删除所有商品?', function(index){
                loading = layer.load(2, {
                    shade: [0.2,'#000']
                });
                jq.post('{:url("taoorder/dels_all")}',function(data){
                    if(data.code == 200){
                        layer.close(loading);
                        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                            location.reload();
                        });
                    }else{
                        layer.close(loading);
                        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
                    }
                });
            });
            return false;
        });

        form.on('submit(delete_all_category)', function(data){
            layer.confirm('<div class="layui-form-item" style="width: 300px;margin-top: 20px;"><label class="layui-form-label">入库分类：</label><div class="layui-input-block"><select id="layui-cid" name="cid" style="width: 150px;padding: 9px 15px;">{volist name="CategoryList" id="vo"}{if condition="$vo.open eq 1"}<option value="{$vo.id}">{$vo.name}</option>{/if}{/volist}</select></div></div>', function(index){
                var cid = jq("#layui-cid").val();
                loading = layer.load(2, {
                    shade: [0.2,'#000']
                });
                jq.post('{:url("taoorder/dels_category")}',{cid:cid},function(data){
                    if(data.code == 200){
                        layer.close(loading);
                        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                            location.reload();
                        });
                    }else{
                        layer.close(loading);
                        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
                    }
                });
            });
            return false;
        });

        form.on('submit(delete_all_time)', function(data){
            layer.confirm('<div class="layui-form-item"><div class="layui-inline"><label class="layui-form-label">开始时间：</label><div class="layui-input-inline"><input type="text" name="startTime" id="startTime" placeholder="yyyy-mm-dd" autocomplete="off" class="layui-input" onclick="layui.laydate({elem: this})"></div></div><div class="layui-inline"><label class="layui-form-label">结束时间：</label><div class="layui-input-inline"><input type="text" name="endTime" id="endTime" placeholder="yyyy-mm-dd" autocomplete="off" class="layui-input" onclick="layui.laydate({elem: this})"></div></div></div>', function(index){
                var startTime = jq("#startTime").val();
                var endTime = jq("#endTime").val();
                loading = layer.load(2, {
                    shade: [0.2,'#000']
                });
                jq.post('{:url("taoorder/dels_time")}',{startTime:startTime,endTime:endTime},function(data){
                    if(data.code == 200){
                        layer.close(loading);
                        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                            location.reload();
                        });
                    }else{
                        layer.close(loading);
                        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
                    }
                });
            });
            return false;
        });
    })
</script>
</body>
</html>